package Events;

import java.util.ArrayList;
import java.util.Random;

/**
 * Factory for events
 * @author Joel Garboden
 */
public class EventFactory
{
  private ArrayList<BaseEvent> eventList;
  private Random r;

  /**
   * Constructor
   * @param eventList list of all events available to the factory.
   * @param r Random for randomization
   */
  public EventFactory(ArrayList<BaseEvent> eventList, Random r)
  {
    this.eventList = eventList;
    this.r = r;
  }

  /**
   * Returns an event from available event list
   * @return a pseudo-random event
   */
  public BaseEvent getAnEvent()
  {
    int eventIndex = r.nextInt(eventList.size());

    return eventList.get(eventIndex);
  }
}
